 <head>
    <link rel="icon" type="image/vnd.microsoft.icon" href="images/bridge.ico">
	<link rel="stylesheet" href="styles/screen.css" type="text/css" media="screen, projection">
	<link rel="stylesheet" href="styles/print.css" type="text/css" media="print">	
	<!--[if lt IE 8]><link rel="stylesheet" href="styles/ie.css" type="text/css" media="screen, projection"><![endif]-->
	<link type="text/css" href="styles/jquery-ui-1.8.1.custom.css" rel="stylesheet" />	
	<link rel="stylesheet" href="styles/gb.css" type="text/css" media="screen">
	<link rel="stylesheet" type="text/css" href="scripts/jsonwidget.css" />
    <script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="scripts/jquery-ui-1.8.1.custom.min.js"></script>	
	<script type="text/javascript" src="scripts/wikid-0.2.js"></script>
	<script type="text/javascript" src="scripts/jquery.parsequery.js"></script>
	<script type="text/javascript" src="scripts/showdown.js"></script>
	<script type="text/javascript" src="scripts/jsonpath-0.8.0.js"></script>	 
	 <script type="text/javascript" src="scripts/jquery.corner.js"></script>
	 <script src="/_utils/script/couch.js?0.11.0"></script> 
	 <script src="/_utils/script/futon.format.js?0.11.0"></script> 
	 <script src="/_utils/script/jquery.couch.js?0.11.0"></script> 
	 <script type="text/javascript" src="scripts/jquery.timeago.js"></script>
	 <script type="text/javascript" src="scripts/jquery.clickmenu.pack.js"></script>
	 <script type="text/javascript" src="scripts/jsonedit.js"></script>
	 <script type="text/javascript" src="scripts/json.js"></script>
	 <script type="text/javascript">
	    $(function() {
			var db_name = wikid.parseDBname(window.location);
			var wikid_id = wikid.parseTopicName(window.location);

			var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"true"});
			var doc = db.open(wikid_id);		
			var result = wikid.toWikid(doc, db);
			$('.readableId').text(result.topic);
			document.title = 'Properties of ' + result.title;

			$('#topic-tab > a').attr("href", "wiki.html?" + wikid_id);

			
var schema = {
  "title":"Properties",
  "type":"map",
  "id":"schemanode",
  "desc":"Properties that tagged topics can use.",
  "required":true,
  "mapping":
  {
    "type":
    {
      "type":"str",
      "required":true,
      "title":"Type (type)",
      "desc":"The datatype of the property (e.g. number, boolean, etc), used for determining the semantics of the variable described",
      "enum":
      [
        "any",
        "str",
        "int",
        "number",
        "bool",
        "seq",
        "map",
        "idref"
      ],
      "desc_enum":
      {
        "any":"Any datatype allowed",
        "str":"String",
        "int":"Integer number",
        "number":"Any number (floating point or integer)",
        "bool":"Boolean (true or false) value",
        "seq":"Nested sequence of items ('array' in many languages).  You must also have a 'sequence' property which is itself a sequence containing a single schema definition",
        "map":"Nested mapping of key/value pairs (a.k.a. 'properties').  You must also have a 'mapping' property which is itself a sequence containing a single schema definition"
      }
    },
    "title":
    {
      "type":"str",
      "title":"Title (title)",
      "desc":"A user-friendly title for the property"
    },
    "id":
    {
      "type":"str",
      "title":"Identifier (id)",
      "desc":"An identifier used to reference this property using the 'idref' property"
    },
    "desc":
    {
      "type":"str",
      "title":"Description (desc)",
      "desc":"A description for use in documentation and context help"
    },
    "user_key":
    {
      "type":"str",
      "title":"User named key (user_key)",
      "desc":"Key for properties named by the user.  Use only when type=map, and ensure there's a corresponding property schema in the mapping"
    },
    "idref":
    {
      "type":"str",
      "title":"Identifier reference (idref)",
      "desc":"Reference to a schema segment with the given 'id' property.  The 'type' attribute must be set to 'idref'."
    },
    "enum":
    {
      "type":"seq",
      "sequence":
      [
        {
          "type":"any"
        }
      ],
      "title":"Enumeration (enum)",
      "desc":"Enumerated sequence of valid values for this property."
    },
    "desc_enum":
    {
      "type":"map",
      "user_key":"enumdesc",
      "mapping":
      {
        "enumdesc":
        {
          "title":"Description for enum value",
          "type":"str",
          "desc":"A mapping containing a description for each possible value listed in the enumeration (enum) property.  Used for documentation and context help."
        }
      }
    },
    "required":
    {
      "type":"bool",
      "title":"Required property? (required)",
      "desc":"If 'true', then this property must always be present"
    },
    "mapping":
    {
      "type":"map",
      "title":"Mapping (mapping)",
      "desc":"A mapping containing schema segments describing each property in the mapping.  The 'type' property must be set to 'map' to use this property.",
      "user_key":"schemachild",
      "mapping":
      {
        "schemachild":
        {
          "type":"idref",
          "idref":"schemanode"
        }
      }
    },
    "sequence":
    {
      "type":"seq",
      "title":"Sequence (sequence)",
      "desc":"A sequence containing a single schema segment",
      "sequence":
      [
        {
          "type":"idref",
          "idref":"schemanode"
        }
      ]
    }
  }
};	
			var je;
			$('#je_schematextarea').val(JSON.stringify(schema));	
			if (doc['-instance'] && doc['-instance'].schema) {	
				$('#je_sourcetextarea').val(JSON.stringify(doc['-instance'].schema));
			}
			je=new jsonwidget.editor();
			je.setView('form');		
		
			$(".save")
				.button()
				.click(function() {
				
					je.updateJSON();
					if (!doc['-instance']) doc['-instance'] = {};
					doc['-instance'].schema = JSON.parse($('#je_sourcetextarea').val());
					db.save(doc);
			})
			$('.button').button();

			

		});
	 </script>
  </head>
  <body>
	<div id="mainsearch" >
		<form action="topic.html">
			<input id="search" type="text" name="name" /> 
		</form>
	</div>  
	 <div class="container">
		<div class="span-24 last">
			&nbsp;
		</div>
		<div class="span-3 left">
			<img id="leftLogo" src="images/gb-logo-trim.png" />
			<a href="index.html">Dashboard</a><br/>
			<a href="topic.html?Conversation">Conversations</a><br/>
			<a href="topic.html?Project">Projects</a><br/>
			<a href="topic.html?Person">People</a><br/>
		</div>
		<div id="contentpane" class="span-20 last  neutral-1" > <!-- content pane -->
			<div class="span-20 last maintabs">	
				<ul id="tabnav"> 
					<li id="topic-tab"><a href="#" class="maintab">Topic</a></li> 
					<li id="audiostream-tab"><a href="#" class="maintab">Audiostream</a></li> 
				</ul>
			</div>
			<div class="span-13 ">&nbsp;</div>
			<div id="title" class="readableId padcontent span-19 last">Title</div>
			<div id="Info" class="padcontent span-19 last content-container">	

				<div id="field_editor" >
					<div id="je_warningdiv">
					</div>
					<div>
						<span id="je_formbutton" style="cursor: pointer">[Edit w/Form]</span>
						<span id="je_sourcebutton" style="cursor: pointer">[Edit Source]</span>		
					</div>
					<div id="je_formdiv" style="text-background: white">
					</div>
					<div>
						<div id="je_schemaformdiv" style="text-background: white">
						</div>
						<textarea id="je_schematextarea" style="display: none" rows="30" cols="80">

						</textarea>
						<form method='POST' id="je_sourcetextform">	
							<textarea id="je_sourcetextarea" rows="30" cols="80" name="sourcearea"></textarea>
						</form>
					</div>    
				</div> <!-- End of field Editor-->
				<div class="space">
					<button class="save">Save</button>
				</div>
			</div> <!-- End of info -->
				
		</div> <!-- End content pane -->
	</div> <!-- End Container -->
	<div class=" footer">
		Footer
	</div>
	</body>
 </html>